import request from '@/utils/request'

export function editDorm(data) { // 修改宿舍
  return request({
    url: `/v1/basic/dormitory`,
    method: 'put',
    params: data
  })
}

export function addDorm(data) { // 添加宿舍
  return request({
    url: `/v1/basic/dormitory`,
    method: 'post',
    data: data
  })
}

export function delDorm(data) { // 删除宿舍
  return request({
    url: `/v1/basic/dormitory`,
    method: 'delete',
    params: data
  })
}

// 获取房间列表
export function rooms(queryParams) {
  return request({
    url: `/v1/basic/room`,
    method: 'GET',
    params: queryParams
  })
}

// 删除房间
export function deleteRoom(id) {
  return request({
    url: `/v1/basic/room?id=${id}`,
    method: 'DELETE'
  })
}

// 编辑房间
export function editRoom(params) {
  return request({
    url: `/v1/basic/room`,
    method: 'PUT',
    params
  })
}

// 创建房间
export function createRoom(data) {
  return request({
    url: `/v1/basic/room`,
    method: 'POST',
    data
  })
}

// 获取宿舍详情
export function dormitory(id) {
  return request({
    url: `/v1/dormitory/${id}`,
    method: 'GET'
  })
}

// 获取房间详情
export function room(id) {
  return request({
    url: `/v1/dormitory/room/${id}`,
    method: 'GET'
  })
}

// 添加房间人员
export const addPersonToRoom = (data) => {
  return request({
    url: '/v1/dormitory/room/user',
    method: 'post',
    data
  })
}

// 修改房间人员
export const editPersonForRoom = (params) => {
  return request({
    url: '/v1/dormitory/room/user',
    method: 'put',
    params
  })
}

// 删除房间人员
export const removePersonFromRoom = (params) => {
  return request({
    url: '/v1/dormitory/room/user',
    method: 'delete',
    params
  })
}
